<?php
if (!defined('APP_PATH')) {
	define('APP_PATH', $_SERVER['DOCUMENT_ROOT']."/bdACPA");
}
require_once(APP_PATH.'/required.php');


$idDossier= intval($_REQUEST["idDossier"]);

//set content type and xml tag
header("Content-type:text/xml");
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
$dossier = null;
$out = "";
if ($idDossier != 0){
	$dossier = $DOSSIER_DAO->rechercher_dossier_pour_formulaire($idDossier);
	print("<data>");
	$out .="<idDossier>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->iddossier)));
	$out .="</idDossier>";
	$out .="<numero>";
	$out .=html_entity_decode(stripcslashes($dossier->numero));
	$out .="</numero>";
	$out .="<foetus>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->foetus)));
	$out .="</foetus>";
	$out .="<sexe>";
	$out .=html_entity_decode(stripcslashes($dossier->sexe));
	$out .="</sexe>";
	$out .="<idCentre>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->idcentre)));
	$out .="</idCentre>";
	$out .="<centre>";
	$centre = $CENTRE_DAO->rechercher_centre_par_id(intval(html_entity_decode(stripcslashes($dossier->idcentre))));
	$out .= $centre->nom;
	$out .="</centre>";
	$out .="<medecin>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->idmedecin)));
	$out .="</medecin>";
	$out .="<atteint>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->atteint)));
	$out .="</atteint>";
	$out .="<categorieBiomed>";
	$out .=intval(html_entity_decode(stripcslashes($dossier->idcategoriebiomed)));
	$out .="</categorieBiomed>";

	$phenotypes = $PHENOTYPE_DAO->rechercher_phenotypeByDossier($idDossier);
	if ($phenotypes != null){
		foreach ($phenotypes as $phenotype) {
			$out .= "<pheno_".$phenotype["idphenotype"].">1</pheno_".$phenotype["idphenotype"].">";
			if ($phenotype["precision"] != null){
				$out .= "<autre_".$phenotype["idphenotype"].">".html_entity_decode(stripcslashes($phenotype["precision"]))."</autre_".$phenotype["idphenotype"].">";
			}
		}
	}
	$out .="<autrephenotype>";
	$out .=html_entity_decode(stripcslashes($dossier->autrephenotype));
	$out .="</autrephenotype>";
	print($out);
	print("</data>");

} else {
	print("<data>");
	$out .="<idDossier>0";
	$out .="</idDossier>";
	$out .="<numero>";
	$out .="</numero>";
	$out .="<foetus>";
	$out .="</foetus>";
	$out .="<sexe>I";
	$out .="</sexe>";
	$out .="<idCentre>";
	$out .= $utilisateur->idcentre;
	$out .="</idCentre>";
	$out .="<centre>";
	$centre = $CENTRE_DAO->rechercher_centre_par_id(intval(html_entity_decode(stripcslashes($utilisateur->idcentre))));
	$out .= $centre->nom;
	$out .="</centre>";
	$out .="<medecin>0";
	$out .="</medecin>";
	$out .="<atteint>0";
	$out .="</atteint>";	
	$out .="<categorieBiomed>0";
	$out .="</categorieBiomed>";
	$out .="<autrephenotype>";
	$out .="</autrephenotype>";


	print($out);
	print("</data>");
}
?>
